﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RozesilaniNovinek
{
    public class KolekceObserveru
    {
        private List<Observer> kolekce = new List<Observer>();
        private INovinka novinka;

        private void InformujKolekci()
        {
            foreach (Observer o in this.kolekce)
            {
                o.Informuj(novinka);
            }
        }

        public void OdhlasObserver(Observer observer)
        {
            this.kolekce.Remove(observer);
        }

        public void PrihlasObserver(Observer observer)
        {
            this.kolekce.Add(observer);
        }

        public INovinka Novinka 
        {
            get {
                return this.novinka;   
            }
            set {
                this.novinka = value;
                InformujKolekci();
            }
        }
    }
}
